<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{common/header :: commonHead}"></head>
<style>
    .modal-backdrop {
        display: none;
    }
    .btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle) {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        width: 120px;
    }
    .add_icon_button:after {
        content: "添加图片";
        width: 100%;
        height: 20px;
        text-align: center;
        display: block;
        margin: 50% 0px 0px 0px;
        font-size: 14px;
        color: #686868;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5 th:text="${null == editable ? '添加优惠券' : '优惠券编辑'}"></h5>
                    <span style="color: red"> （带*号必填）</span>
                    <div class="ibox-tools">
                        <a href="javascript: window.location.href='/coupon/list';" title="返回"><i class="glyphicon glyphicon-remove"></i></a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="row form-body form-horizontal m-t" id="" method="post" th:action="${null == editable ? '/coupon/add' : '/coupon/edit'}">
                        <div class="col-md-12 droppable sortable ui-droppable ui-sortable">
                            <div class="form-group draggable ui-draggable dropped" style="display: none">
                                <label class="col-sm-3 control-label">ID：</label>
                                <div class="col-sm-2">
                                    <input name="id" th:value="${editable?.id}">
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>请绑定业态或商户：</label>
                                <div class="col-sm-6">
                                    <select class="form-control" name="bindType" id="bind_type">
                                        <option value="">-请绑定业态或商户(注:如果不选择业态和商户为商管端核销)-</option>
                                        <!--1.绑定商户 2.绑定业态-->
                                        <option th:selected="${editable?.bindType == 1}" value="1">绑定商户</option>
                                        <option th:selected="${editable?.bindType == 2}" value="2">绑定业态</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" th:style="${'position: static; display:' + (editable?.bindType == null || editable?.bindType == 2 ? 'none' : 'block')}" id="add-store-list">
                                <label class="col-sm-3 control-label">选择商铺：</label>
                                <div class="col-sm-2">
                                    <a class="btn btn-primary btn-sm modal-trigger" data-toggle="modal" data-target="#storeModal"><i class="glyphicon glyphicon-plus-sign"></i>添加商铺</a>
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" th:style="${'position: static; display:' + (editable?.bindType == null || editable?.bindType == 1 ? 'none' : 'block')}" id="add-commercial-list">
                                <label class="col-sm-3 control-label">选择业态：</label>
                                <div class="col-sm-2">
                                    <a class="btn btn-primary btn-sm modal-trigger" data-toggle="modal" data-target="#commercialModal"><i class="glyphicon glyphicon-plus-sign"></i>添加业态</a>
                                </div>
                            </div>
                            <!-- 上传图片 -->
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>上传图片：</label>
                                <div class="col-sm-2">
                                    <div class="add_icons">
                                        <div class="add_icon_pan" style="width: 210px">
                                            <input name="01_image"
                                                   id="upload_pic_image" type="file"
                                                   accept="image/*"
                                                   control_id="image"
                                                   image_id="imageId"
                                                   class="upload_pic_input" logo="1">
                                            <input class="form-control" id="imageId" name="imageIds" type="text" th:value="${editable?.imageId}" style="display: none;">
                                            <input class="form-control" id="image" name="image" type="text" th:value="${editable?.image}" style="display: none;">
                                            <img id="uploaded_pic_logo" th:class="${editable?.image != null ? '' : 'hide' }"
                                                 th:src="${editable?.image != null ? editable.image : ''}"/>
                                            <div th:class="'mark ' + ${editable?.image != null ? '' : 'hide' }">
                                                <div class="close_icon_button"
                                                     control_id="image" image_id="imageId"></div>
                                            </div>
                                            <label for="upload_pic_image"
                                                   th:class="'add_icon_button ' + ${editable?.image != null ? 'hide' : ''}"></label>
                                        </div>
                                    </div>
                                    <label class="help-block">logo 4:3,尺寸800*600</label>
                                </div>
                                <div class="col-sm-3">
                                    <div class="add_icons">
                                        <div class="add_icon_pan" style="width: 210px">
                                            <input name="02_picture"
                                                   id="upload_picture" type="file"
                                                   accept="image/*"
                                                   control_id="picture"
                                                   image_id="pictureId"
                                                   class="upload_pic_input">
                                            <input class="form-control" id="pictureId" name="imageIds" type="text" th:value="${editable?.pictureId}" style="display: none;">
                                            <input class="form-control" id="picture" name="picture" type="text" th:value="${editable?.picture}" style="display: none;">
                                            <img id="uploaded_picture" th:class="${editable?.picture != null ? '' : 'hide' }"
                                                 th:src="${editable?.picture != null ? editable.picture : ''}"/>
                                            <div th:class="'mark ' + ${editable?.picture != null ? '' : 'hide' }">
                                                <div class="close_icon_button"
                                                     control_id="picture" image_id="pictureId"></div>
                                            </div>
                                            <label for="upload_picture"
                                                   th:class="'add_icon_button ' + ${editable?.picture != null ? 'hide' : ''}"></label>
                                        </div>
                                    </div>
                                    <label class="help-block">大图16:9,尺寸720*405</label>
                                </div>
                            </div>
                            <!-- 优惠券名称 -->
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>优惠券名称：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="name" class="form-control" th:value="${editable?.name }" required="required" placeholder="请输入优惠券名称">
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>优惠券类型：</label>
                                <div class="col-sm-6">
                                    <select class="form-control" name="type">
                                        <option value="">-选择类型-</option>
                                        <option th:selected="${editable?.type == 1}" value="1">优惠券</option>
                                        <option th:selected="${editable?.type == 3}" value="3">停车券</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>券折扣类型：</label>
                                <div class="col-sm-6">
                                    <select class="form-control" required name="disType" id="distype-selector">
                                        <option value="">-券折扣类型-</option>
                                        <!--1.指定日期 2.领取优惠券后指定小时数 3.领取当天-->
                                        <option th:selected="${editable?.disType == 1}" value="1">折扣</option>
                                        <option th:selected="${editable?.disType == 2}" value="2">固定金额</option>
                                        <option th:selected="${editable?.disType == 3}" value="3">固定时长(仅限停车券选择)</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped"  style="position: static;" id="dis_value">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>折扣值：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="disValue" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" placeholder="请填写折扣值(当选择折扣类型为时长时，请填写相应时长)" id="disValue" class="form-control" th:value="${editable?.disValue}">
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">券购买支付类型：</label>
                                <div class="col-sm-6">
                                    <select class="form-control" required name="valueType" id="valuetype-selector">
                                        <option value="">-选择类型-</option>
                                        <option th:selected="${editable?.valueType == 1}" value="1">积分</option>
                                        <option th:selected="${editable?.valueType == 2}" value="2">积分+金额</option>
                                        <option th:selected="${editable?.valueType == 3}" value="3">金额</option>
                                    </select>
                                </div>
                            </div>
                            <!-- 输入积分值 -->
                            <div class="form-group draggable ui-draggable dropped" th:style="${'position: static; display:' + (editable == null || editable?.valueType == 3 ? 'none' : 'block')}" id="total-integral-input">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>价值积分：</label>
                                <div class="col-sm-6">
                                    <input onkeyup="value=value.replace(/^0(0+)|[^\d]+/g,'')" type="text" id="integral" name="integral" class="form-control" th:value="${editable?.integral }" placeholder="请输入优惠券积分价值">
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" th:style="${'position: static; display:' + (editable == null || editable?.valueType == 1 ? 'none' : 'block')}" id="total-price-input">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>价值金额：</label>
                                <div class="col-sm-6">
                                    <input type="text" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" name="price" placeholder="请填写优惠券价值(￥)" id="price" class="form-control" th:value="${editable?.price}">
                                </div>
                            </div>
                            <!-- 券数量类型 -->
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">总量限制：</label>
                                <div class="col-sm-6">
                                    <select required class="form-control" name="sumType" id="sumtype-selector">
                                        <option value="">-券量限制-</option>
                                        <option th:selected="${editable?.sumType == 0}" value="0">限量</option>
                                        <option th:selected="${editable?.sumType == 1}" value="1">不限量</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" th:style="${'position: static; display:' + (editable == null || editable?.sumType == 1 ? 'none' : 'block')}" id="total-input">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>设置总量：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="sumTatal" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" onblur="v();" placeholder="请填写优惠券总量" id="sumTotal" class="form-control" th:value="${editable?.sumTatal}">
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>券有效期类型：</label>
                                <div class="col-sm-6">
                                    <select required class="form-control" name="useTimeType" id="usetimetype-selector">
                                        <!--<input name="useTimeType" th:value="${editable?.useTimeType == null ? '1' : editable?.useTimeType}">-->
                                        <option value="">-券有效期类型-</option>
                                        <!--1.指定日期 2.领取优惠券后指定小时数 3.领取当天-->
                                        <option th:selected="${editable?.useTimeType == 1}" value="1">指定日期</option>
                                        <option th:selected="${editable?.useTimeType == 2}" value="2">领取优惠券后指定小时数</option>
                                        <option th:selected="${editable?.useTimeType == 3}" value="3">领取当天</option>
                                    </select>
                                </div>
                            </div>
                            <!-- 优惠券有效期 useTimeType == 1-->
                            <div class="form-group draggable ui-draggable dropped"  th:style="${'position: static; display:' + (editable?.useTimeType == 1 ? 'block' : 'none')}" id="total-input-use">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>有效期：</label>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" class="form-control" readonly id="coupon_start_date" placeholder="开始时间" th:value="${editable?.useTimeStart}" name="useTimeStart" >
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" class="form-control" readonly id="coupon_end_date" placeholder="结束时间" th:value="${editable?.useTimeEnd}" name="useTimeEnd">
                                    </div>
                                </div>
                                <span style="color: grey;line-height: 31px;">(注:券的实际使用时间限制)</span>
                            </div>
                            <!-- 优惠券有效期 useTimeType == 2-->
                            <div class="form-group draggable ui-draggable dropped" th:style="${'position: static; display:' + (editable?.useTimeType == 2 ? 'block' : 'none')}" id="total-input-hour">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>有效期：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="useTimeHour" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"  placeholder="领取优惠券后指定过期小时数" id="coupon-time-hour" class="form-control" th:value="${editable?.useTimeHour}">
                                </div>
                                <span style="color: grey;line-height: 31px;">(注:券的实际使用时间限制)</span>
                            </div>
                            <!-- 优惠券购买时间 -->
                            <div class="form-group draggable ui-draggable dropped"  style="position: static;">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>购买时限：</label>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" class="form-control" required readonly placeholder="开始时间" id="buy_time_start" th:value="${editable?.buyTimeStart}" name="buyTimeStart" >
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" class="form-control" required readonly placeholder="结束时间" id="buy_time_end" th:value="${editable?.buyTimeEnd}" name="buyTimeEnd">
                                    </div>
                                </div>
                                <span style="color: grey;line-height: 31px;">(注:券的实际可购买时间限制)</span>
                            </div>

                            <div class="form-group draggable ui-draggable dropped"  style="position: static;">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>展示时间：</label>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" required class="form-control" readonly placeholder="开始时间" id="show_start_time" th:value="${editable?.showTimeStart}" name="showTimeStart" >
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" required class="form-control" readonly placeholder="结束时间" id="show_end_time" th:value="${editable?.showTimeEnd}" name="showTimeEnd">
                                    </div>
                                </div>
                                <span style="color: grey;line-height: 31px;">(注:券的实际展示时间限制)</span>
                            </div>
                            <!--<div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">展示时间：</label>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" class="form-control" readonly id="show_start_date" placeholder="开始时间" th:value="${editable?.showTimeStart}" name="showTimeStart" >
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" class="form-control" readonly id="show_end_date" placeholder="结束时间" th:value="${editable?.showTimeEnd}" name="showTimeEnd">
                                    </div>
                                </div>
                                <span style="color: red;font-size: 30px">*</span>
                            </div>-->
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">日限数量：</label>
                                <div class="col-sm-6">
                                    <input type="text" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" onblur="v();" placeholder="请输入每天最大购买数量 (注：此项若不填，即为当日不限购)" name="count" class="form-control" th:value="${editable?.count }">
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label">期限数量：</label>
                                <div class="col-sm-6">
                                    <input type="text" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" placeholder="请输入有效期内最大购买数量 (注：此项若不填，即为购买时限内不限购)" name="buyTimeCount" class="form-control" th:value="${editable?.buyTimeCount }">
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static;display: none">
                                <label class="col-sm-3 control-label">上下架：</label>
                                <div class="col-sm-6">
                                    <input name="status" th:value="${editable?.status == null ? '0' : editable?.status}">
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static;display: none">
                                <label class="col-sm-3 control-label">是否只推送：</label>
                                <div class="col-sm-6">
                                    <input name="statusShow" th:value="${editable?.statusShow == null ? '0' : editable?.status}">
                                </div>
                            </div>
                            <!-- <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                 <label class="col-sm-3 control-label"><span style="color: red;">* </span>是否只推送：</label>
                                 <div class="col-sm-6">
                                     <div class="radio radio-info radio-inline" style="vertical-align: unset">
                                         <input type="radio" id="inlineRadio1" name="statusShow" value="1" onclick="$(this).attr('checked','checked');$('#inlineRadio2').removeAttr('checked')" th:checked="${editable?.statusShow == 1}">
                                         <label for="inlineRadio1">是 </label>
                                     </div>
                                     <div class="radio radio-danger radio-inline" style="vertical-align: unset">
                                         <input type="radio" id="inlineRadio2" name="statusShow" value="0" onclick="$(this).attr('checked','checked');$('#inlineRadio1').removeAttr('checked')" th:checked="${editable?.statusShow == 0}">
                                         <label for="inlineRadio2">否 </label>
                                     </div>
                                     <span style="color: grey;line-height: 31px;">(注:是，只可以通过后台推送，前端不展示，否，既可以通过后台推送，上架后可以前端展示)</span>
                                 </div>
                             </div>-->
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>是否上首页推荐：</label>
                                <div class="col-sm-6">
                                    <div class="radio radio-info radio-inline">
                                        <input type="radio" id="inlineRadio3" name="statusHot" value="1" onclick="$(this).attr('checked','checked');$('#inlineRadio4').removeAttr('checked')" th:checked="${editable?.statusHot == 1}">
                                        <label for="inlineRadio3">是 </label>
                                    </div>
                                    <div class="radio radio-danger radio-inline">
                                        <input type="radio" id="inlineRadio4" name="statusHot" value="0" onclick="$(this).attr('checked','checked');$('#inlineRadio3').removeAttr('checked')" th:checked="${editable?.statusHot == 0}">
                                        <label for="inlineRadio4">否 </label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>使用规则：</label>
                                <div class="col-sm-6">
                                    <textarea id="useRule" class="myEditor" placeholder="请输入优惠券使用规则" name="useRule" th:text="${editable?.useRule}"></textarea>
                                </div>
                            </div>
                            <div class="form-group draggable ui-draggable dropped" style="position: static;">
                                <label class="col-sm-3 control-label"><span style="color: red;">* </span>简介：</label>
                                <div class="col-sm-6">
                                    <textarea id="couponDesc" name="couponDesc" class="myEditor" th:text="${editable?.couponDesc}" placeholder="请输入优惠券简介"></textarea>
                                </div>
                            </div>
                            <div class="modal fade" id="storeModal" tabindex="-1" draggable="true" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog" style="width: 800px;">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalLabel">选择商户</h4>
                                        </div>
                                        <div class="modal-body">
                                            <div style="display: none">
                                                <input id="storeIds" th:value="${editable?.storeIdList}">
                                            </div>
                                            <div>
                                                <select multiple="multiple" style="height: 200px" name="storeIdList" class="store-selector"></select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="modal fade" id="commercialModal" tabindex="-1" draggable="true" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog" style="width: 800px;">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalCommercial">选择业态</h4>
                                        </div>
                                        <div class="modal-body">
                                            <div style="display: none">
                                                <input id="commercialIds" th:value="${editable?.commercialIdList}">
                                            </div>
                                            <div>
                                                <select multiple="multiple" style="height: 200px" name="commercialIdList" class="commercial-selector"></select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <div class="col-sm-12 col-sm-offset-3">
                                    <button class="btn btn-primary" id="submit-form" type="submit">保存内容</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="/js/plugins/chosen/chosen.jquery.js"></script>
<script th:inline="javascript">
    let imageId;
    let pictureId;
    $("#submit-form").click(()=>{
        imageId = $("#imageId").val();
    pictureId = $("#pictureId").val();
    if (imageId==null||imageId==''){
        layer.msg("请上传优惠券logo图片",{time: 500})
        return false;
    }
    if (pictureId==null||pictureId==''){
        layer.msg("请上传优惠券banner图片",{time: 500})
        return false;
    }
    });
    let buyStart;
    let buyEnd;
    $("#buy_time_start").change(()=>{
        buyStart = $("#buy_time_start").val();
    });
    $("#buy_time_end").change(()=>{
        buyEnd = $("#buy_time_end").val();
    if (buyEnd < buyStart) {
        layer.msg("结束时间不能小于开始时间",{time: 500})
        $("#buy_time_end").val('');
    }
    });
    let couponStart;
    let couponEnd;
    $("#coupon_start_date").change(()=>{
        couponStart = $("#coupon_start_date").val();
    });
    $("#coupon_end_date").change(()=>{
        couponEnd = $("#coupon_end_date").val();
    if (couponEnd < couponStart) {
        layer.msg("结束时间不能小于开始时间",{time: 500})
        $("#coupon_end_date").val('');
    }
    });

    let showStart;
    let showEnd;
    $("#show_start_time").change(()=>{
        console.log($("#show_start_time").val())
        showStart = $("#show_start_time").val();
    });
    $("#show_end_time").change(()=>{
        showEnd = $("#show_end_time").val();
    if (showEnd < showStart) {
        layer.msg("结束时间不能小于开始时间",{time: 500})
        $("#show_end_date").val('');
    }
    });

    $(".modal-backdrop").remove();
    $(function () {
        let storeIds = $("#storeIds").val().toString().replace("[","").replace("]","").replace(/\s*/g,"");
        console.log(storeIds);
        //初始化商户信息
        initListBox('/store/query','store-selector',storeIds);
        console.log($('[name="storeIdList"]').val());
    });

    $(function () {
        let commercialIds = $("#commercialIds").val().toString().replace("[","").replace("]","").replace(/\s*/g,"");
        console.log(commercialIds);
        //初始化业态信息
        initCommercialListBox('/commercial/query','commercial-selector',commercialIds);
        console.log($('[name="commercialIdList"]').val());
    });

    $("#sumtype-selector").change(function () {
        let selection = $(this).val();
        if (selection == 0) {
            $("#total-input").css('display','block');
            $("#sumTotal").attr('required','required');
        }
        if (selection == '' || selection == 1) {
            $("#total-input").css('display','none');
        }
    })

    $("#usetimetype-selector").change(function () {
        let selection = $(this).val();
        if (selection == 1) {
            $("#total-input-use").css('display','block');
            $("#total-input-hour").css('display','none');
        }
        if (selection == 2) {
            $("#total-input-use").css('display','none');
            $("#total-input-hour").css('display','block');
        }
        if (selection == '' || selection == 3) {
            $("#total-input-use").css('display','none');
            $("#total-input-hour").css('display','none');
        }
    })
    $("#bind_type").change(function () {
        let selection = $(this).val();
        if (selection == 1) {
            $("#add-store-list").css('display','block');
            $("#add-commercial-list").css('display','none');
        }
        if (selection == 2) {
            $("#add-store-list").css('display','none');
            $("#add-commercial-list").css('display','block');
        }
        if (selection == '') {
            $("#add-store-list").css('display','none');
            $("#add-commercial-list").css('display','none');
        }
    })

    $("#valuetype-selector").change(function () {
        let selection = $(this).val();
        if (selection == 1) {
            $("#total-integral-input").css('display','block');
            $("#total-price-input").css('display','none');
            $("#integral").attr('required','required');
            $("#price").removeAttrs('required');
        }
        if (selection == 2) {
            $("#total-integral-input").css('display','block');
            $("#total-price-input").css('display','block');
            $("#integral").attr('required','required');
            $("#price").attr('required','required');
        }
        if (selection == 3) {
            $("#total-integral-input").css('display','none');
            $("#total-price-input").css('display','block');
            $("#integral").removeAttrs('required');
            $("#price").attr('required','required');
        }
    })
    $("#distype-selector").change(function () {
        let selection = $(this).val();
        if (selection == 1||selection == 2||selection == 3) {
            $("#dis_value").css('display','block');
            $("#dis_value").attr('required','required');
        }else {
            $("#dis_value").css('display','none');
            $("#dis_value").removeAttrs('required');
        }
    })


</script>
</html>